﻿@{
    ViewBag.Title = "查询添加存储设备";
    Layout = "~/Views/Shared/PlanPartial/_LayoutSearch.cshtml";
}

@{
    var Key = ViewData["Key"] as string;
}
<div>
    <input type="hidden" value="@(Key)" id="searchKey" />
    <input type="text" style="width: 300px;" value="@(Key)" class="easyui-searchbox" data-options="prompt:'输入IP地址进行搜索',searcher:doSearch" />
</div>
<div style="padding: 10px 0;">
    <table id="StorageSys" class="" title="存储"
        fitcolumns="true" pagination="true">
        <thead>
            <tr>
                <th data-options="field:'ck',checkbox:true">全选</th>
                <th field="Model" width="120" sortable="true">存储型号</th>
                <th field="IPAddress" width="120" sortable="true">管理IP地址</th>
            </tr>
        </thead>
    </table>
</div>
<script type="text/javascript">
    var doSearch = function (value) {
        var parenter = GetParentWindow(),
            list = [];
        if (parenter) {
            list = parenter.InspObj.GetRequestIDList('StorageSys');
        }

        var query = { Key: value, ExcludeIDList: JSON.stringify(list) };
        $('#StorageSys').datagrid('load', query);
    };

    var AddRow = function () {
        var parenter = GetParentWindow();

        if (parenter) {

            var selects = parenter.InspObj.SelectArray["StorageSys"] || [];

            if (selects.length) {
                parenter.InspObj.AddStorageSystem(selects);
                parenter.InspObj.SelectArray["StorageSys"] = [];
                closeWindow();
            }
        }
    };

    $(function () {
        var parenter = GetParentWindow(),
            list = [];
        if (parenter) {
            list = parenter.InspObj.GetRequestIDList('StorageSys');
        }

        var query = { Key: $('#searchKey').val(), ExcludeIDList: JSON.stringify(list) };

        $('#StorageSys').datagrid({
            url: '/PlanManagement/SearchStorageResult',
            pageList: [10],
            pageSize: 10,
            pageNumber: 1,
            queryParams: query,
            onLoadSuccess: function (data) {
                parenter.InspObj.onLoadSuccess(data.rows, "StorageSys", $('#StorageSys'));
            },
            onCheck: function (index, row) {
                parenter.InspObj.OnSelect(index, row, "StorageSys");
            },
            onUncheck: function (index, row) {
                parenter.InspObj.OnUnSelect(index, row, "StorageSys");
            },
            onCheckAll: function (rows) {
                parenter.InspObj.OnSelectAll(rows, "StorageSys");
            },
            onUncheckAll: function (rows) {
                parenter.InspObj.OnUnSelectAll(rows, "StorageSys");
            }
        });

        var p2 = $('#StorageSys').datagrid('getPager');
        $(p2).pagination({
            beforePageText: '第',
            afterPageText: '页&nbsp;共&nbsp;{pages}&nbsp;页',
            displayMsg: '当前显示{from} - {to}&nbsp;条记录&nbsp;共&nbsp;{total}&nbsp;条记录'

        });
    });
</script>
